object work {;import org.scalaide.worksheet.runtime.library.WorksheetSupport._; def main(args: Array[String])=$execute{;$skip(56); 
	println("Welcome to the Scala worksheet");$skip(53); 


	def from(x: Int): Stream[Int] = x #:: from(x + 1);System.out.println("""from: (x: Int)Stream[Int]""");$skip(46); 

	from(0).take(5).foreach(x=> print(x + ","));$skip(111); 
	
	def fib: Stream[Int] = {
		def f(x: Int, y: Int): Stream[Int] = (x + y) #:: f(y, x + y)
		 0 #:: f(0, 1)
	};System.out.println("""fib: => Stream[Int]""");$skip(42); 
	fib.take(10).foreach(x=> print(x + ","));$skip(72); 
	
	
	def fib2(x: Int, y: Int): Stream[Int] = (x + y) #:: fib2(y, x + y);System.out.println("""fib2: (x: Int, y: Int)Stream[Int]""");$skip(45); 
	fib2(1,2).take(10).foreach(x=>print(x+","));$skip(76); 
	def ronda1(x: Int): Stream[Int] = (x) #:: ronda1(if (x >= 0) -x-1 else -x);System.out.println("""ronda1: (x: Int)Stream[Int]""");$skip(47); 
	ronda1(0).take(15).foreach(x=>print(x + ","));$skip(88); 


	def ronda(c:Int, x: Int): Stream[Int] = (c+x) #:: ronda(c, if (x >= 0) -x-1 else -x);System.out.println("""ronda: (c: Int, x: Int)Stream[Int]""");$skip(50); 
	ronda(10, 0).take(15).foreach(x=>print(x + ","));$skip(102); 
                                                  
	ronda(10, 0).take(15).foreach(x=>print(x + ","))}
	
		
}